import SwiftUI

struct KnowledgeBaseView: View {
    @State private var searchText = ""
    
    var body: some View {
        NavigationView {
            List {
                Section(header: Text("修炼心法")) {
                    ForEach(0..<3) { _ in
                        NavigationLink(destination: Text("心法详情")) {
                            VStack(alignment: .leading, spacing: 4) {
                                Text("基础心法要诀")
                                    .font(.system(size: 17))
                                Text("内息运行的基本原理与方法")
                                    .font(.subheadline)
                                    .foregroundColor(.secondary)
                            }
                            .padding(.vertical, 4)
                        }
                    }
                }
                
                Section(header: Text("技能图谱")) {
                    ForEach(0..<3) { _ in
                        NavigationLink(destination: Text("技能详情")) {
                            VStack(alignment: .leading, spacing: 4) {
                                Text("剑法进阶")
                                    .font(.system(size: 17))
                                Text("从基础到精通的进阶路线")
                                    .font(.subheadline)
                                    .foregroundColor(.secondary)
                            }
                            .padding(.vertical, 4)
                        }
                    }
                }
                
                Section(header: Text("修炼笔记")) {
                    ForEach(0..<3) { _ in
                        NavigationLink(destination: Text("笔记详情")) {
                            VStack(alignment: .leading, spacing: 4) {
                                Text("突破心得")
                                    .font(.system(size: 17))
                                HStack {
                                    Text("记录修炼过程中的感悟与经验")
                                        .font(.subheadline)
                                        .foregroundColor(.secondary)
                                    Spacer()
                                    Text("2天前")
                                        .font(.caption)
                                        .foregroundColor(.secondary)
                                }
                            }
                            .padding(.vertical, 4)
                        }
                    }
                }
            }
            .navigationTitle("知识库")
            .searchable(text: $searchText, prompt: "搜索修炼知识")
            .toolbar {
                ToolbarItem(placement: .navigationBarTrailing) {
                    Button(action: {}) {
                        Image(systemName: "square.and.pencil")
                    }
                }
            }
        }
    }
}

